#include "handsmoveevent.h"

using namespace mlgesture;
using namespace std;
using namespace cv;

HandsMoveEvent::HandsMoveEvent(const vector<Point> centers, const vector<Rect> &rects) {
	type_ = GestureEvent::MOVE_EVENT;
	for (size_t i=0; i<centers.size(); i++) {
		centers_.push_back(centers[i]);
		rects_.push_back(rects[i]);
	}
	if (centers.size() == 2) {
		int dx = centers[1].x - centers[0].x;
		int dy =centers[1].y - centers[0].y;
		distance_ = sqrt((float)dx*dx+dy*dy);
		angle_ = atan(1.*dy/dx);
	}
}

void HandsMoveEvent::getCenters(std::vector<cv::Point> &centers) const {
	centers.clear();
	for (size_t i=0; i<centers_.size(); i++) {
		centers.push_back(centers_[i]);
	}
}

void HandsMoveEvent::getRects(std::vector<cv::Rect> &rects) const {
	rects.clear();
	for (size_t i=0; i<rects_.size(); i++) {
		rects.push_back(rects_[i]);
	}
}


float HandsMoveEvent::getAngle() const {
	return angle_;
}

float HandsMoveEvent::getDistance() const {
	return distance_;
}
